import React from "react";
import { connect } from "react-redux";
import * as actions_history from "@/store/actions/history";
import {push} from 'connected-react-router';
import store from '@/store'

class Connect extends React.Component {
  componentDidMount() {
    console.log("ConnectedRouter", this);
  }
  render() {
    return (
      <div>
        <h6>ConnectedRouter</h6>
        <h6>{this.props.name}</h6>
        <button onClick={()=>{this.props.history.push('/')}}>原生history跳路由</button>
        <button onClick={()=>{store.dispatch(push('/'))}}>store.dispatch跳路由</button>
        <button onClick={()=>{this.props.go('/')}}>在仓库中调路径</button>
      </div>
    );
  }
}
const mapStateToProps = state => ({
  pathname: state.router.location.pathname,
  search: state.router.location.search,
  hash: state.router.location.hash,
  test:state.test
})

export default connect(mapStateToProps, {...actions_history})(Connect);
